//引入
//import { JSEncrypt } from "jsencrypt";
import { JSEncrypt } from "encryptlong";
/**
 * 加密
 * @param {String}  需要加密的参数
 */
export function encryption(param) {
	// 后台给的公钥
	let publicKey =
		"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwtGdKVMqrPlpLknC+vR1Iz6iTZLQSZTtuMYccQlYSBjl4Fn0U1jDdl1qzR4/3eGUvnXm2zXbOymqAtuFvmZUjBNTeSxFbgxsSz1KbME0YWQ8lX/mgTHALElfo+m3+ndSub4ziPSpeoxHln94bE6cnAU7ItnDsmkDNqNcBuVKfBkzAI9EVvQPHgNevvtzJUf8Vp4l9UNgPQ7aD2ldplU1RTEB/JQcMOpcBrfyDgi801aeZZywlf9nc0AFmbyxt68+tKZK1wL16Flc40pDm+5dQEyTL9h9nzPW6SEDDWw/tgecQCh58jM9xERJbt5EK1i0cv7gtq/3HuSQ0+0AsVSzGwIDAQAB";
	//let encryptor = new JSEncrypt(); // 新建JSEncrypt对象
	let encryptor = new JSEncrypt(); // 新建JSEncrypt对象
	encryptor.setPublicKey(
		"-----BEGIN PUBLIC KEY-----" + publicKey + "-----END PUBLIC KEY-----"
	); // 设置公钥
	//let passwordEncryp = encryptor.encrypt(param); // 对密码进行加密
	let encryptValue = encryptor.encryptLong(param);
	//return passwordEncryp;
	return encryptValue;
}

// 解密
export function decrypt(msg) {
	const privateKey =
		"MIIEpAIBAAKCAQEAwtGdKVMqrPlpLknC+vR1Iz6iTZLQSZTtuMYccQlYSBjl4Fn0U1jDdl1qzR4/3eGUvnXm2zXbOymqAtuFvmZUjBNTeSxFbgxsSz1KbME0YWQ8lX/mgTHALElfo+m3+ndSub4ziPSpeoxHln94bE6cnAU7ItnDsmkDNqNcBuVKfBkzAI9EVvQPHgNevvtzJUf8Vp4l9UNgPQ7aD2ldplU1RTEB/JQcMOpcBrfyDgi801aeZZywlf9nc0AFmbyxt68+tKZK1wL16Flc40pDm+5dQEyTL9h9nzPW6SEDDWw/tgecQC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UpLt0ErSIGfd2KVYc5QKBgQC8YyaaHSEmhaiwTV948YxKysv3pN0d3xLHsMJNLikN6gfUS4HRB5fXYil0ApaMfoEL8vdW0LTRw60iYN1xEHJvF6em3welPyvA3nPghf3w8yAkx5MbvjVMi/7AcmZA30ny5hFYvzPcfqeh1HWq9XkVyNgpFoy2fm7XlrpcbAFHfw==";
	//let decrypt = new JSEncrypt();
	let decrypt = new JSEncrypt();
	decrypt.setPrivateKey(
		"-----BEGIN RSA PRIVATE KEY-----" +
			privateKey +
			"-----END RSA PRIVATE KEY-----"
	);
	// var decryptMsg = decrypt.decrypt(msg);
	var decryptMsg = decrypt.decryptLong(msg);
	return decryptMsg;
}
